package cn.zyl.demo.common.exception;

import cn.zyl.demo.common.enums.MsgEnum;
import cn.zyl.demo.common.permanent.MsgProperties;

/**
 * CryptoHandlerException异常类说明:
 *
 * @author wsz
 * @version v1.0
 * @date 2020-07-22
 */
public class CryptoHandlerException extends RuntimeException {
    public CryptoHandlerException(String msg) {
        super(msg);
    }

    public CryptoHandlerException(Throwable e) {
        super(e);
    }

    public CryptoHandlerException(String msg, Throwable e) {
        super(msg, e);
    }

    public static void isTrueThrow(boolean boo, String msg) throws CryptoHandlerException {
        if (boo) { throw new CryptoHandlerException(msg); }
    }
    public static void isTrueThrow(boolean boo, MsgEnum msg) throws CryptoHandlerException {
        if (boo) { throw new CryptoHandlerException(MsgProperties.get(msg)); }
    }
    public static void isNullThrow(Object o, String msg) throws CryptoHandlerException {
        isTrueThrow(null==o,msg);
    }
    public static void isNullThrow(Object o, MsgEnum msg) throws CryptoHandlerException {
        isTrueThrow(null==o,msg);
    }
    public static void isTrueThrow(boolean boo, Throwable e) throws CryptoHandlerException {
        if (boo) { throw new CryptoHandlerException(e); }
    }
}